package momo;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

import momo.Image;

/**
 * 
 * @author Mohamed.Mosa@lu.unisi.ch
 * @version April 27th
 *
 */

public class LibraryManager implements Serializable {
	HashMap<String, String> tag = new HashMap<String, String>();
	static Image img = new Image(null);
	ArrayList<Image> library;
	
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
	
		//SERIALIZATION
		try {
			FileOutputStream fileStream = new FileOutputStream("librarySave.lib");
			ObjectOutputStream os = new ObjectOutputStream(fileStream);
			os.writeObject(img);
			os.close();
			
		} catch (FileNotFoundException e) {
			
			e.printStackTrace();
		}
		
		
		//DESERIALIZATION
		try {
			FileInputStream filestream = new FileInputStream("librarySave.lib");
			ObjectInputStream os = new ObjectInputStream(filestream);
			Object one = os.readObject();
			Image image = (Image) img;
			//System.out.println(one);
			System.out.println(image);
			os.close();	
			
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}
}
